﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Century.Common;
using Century.Model.ViewModel;
using Century.EnterpriseLibrary.Caching;
using Century.Model.CMS;
using Century.Business.CMS;
using Century.Web.Security.Filters;
using Century.Web.UI.MVC.Filters;

namespace Century.Web.UI.MVC
{
    [InitializeSimpleMembership]
    [InitializeCenturyDbContext]
    public class BaseController : System.Web.Mvc.Controller
    {
        //protected ISiteService siteService = new SiteService();
        protected ISiteService siteService { get; set; }

        public BaseController(ISiteService siteService)
        {
            this.siteService = siteService;
        }

        protected UserToken Token
        {
            get
            {
                return FrameworkToken.UserToken;
            }
        }
        protected Site CurrentSite
        {
            get
            {

                return FrameworkToken.UserToken.CurrentSite;
            }
        }
        protected SitePage CurrentPage
        {
            get
            {
                string pageName = HttpContext.Request.RequestContext.RouteData.Values["pgName"].ToString();
                return siteService.GetPage(pageName, CurrentSite.Id);
            }
        }
        //protected List<CharValueDTO> GetCharValues(CharacteristicType characteristicType)
        //{
        //    return CharacteristicService.GetCharValues(characteristicType);
        //}

    }

    //class CacheTestClass
    //{
    //    public void Test()
    //    {
    //        //Cache Object for 15 minuts
    //        var result = CacheService.Instance.Get("CacheKey_1", GetMyClassFromDB, new TimeSpan(0, 15, 0));
    //    }

    //    public List<MyClass> GetMyClassFromDB()
    //    {
    //        return new List<MyClass>();
    //    }
    //}
    //public class MyClass
    //{
    //    public int ID { get; set; }
    //    public int MyProperty { get; set; }
    //}
}
